package src.lanqiao.true_question_B;

import java.util.Scanner;


/**
 * 输入一组数，最少要添加多少个数，能成为等差数列
 * 输出这个等差数列的个数
 *
 * input: 5
 *        2 6 4 10 20
 *
 * output: 10
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(getSpecialNumSum(n));
    }

    private static int getSpecialNumSum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            if(isSpecialNumSum(i)) sum += i;
        }
        return sum;
    }

    private static boolean isSpecialNumSum(int i) {

        while(i != 0) {
            int t = i % 10;
            if (t == 2 || t == 0|| t == 1|| t == 9) return true;
            i = i / 10;
        }

        return false;
    }
}
